<!DOCTYPE html>
<html lang='en'>

<head>
  <meta charset='UTF-8'>
  <meta http-equiv='X-UA-Compatible' content='IE=edge'>
  <meta name='viewport' content='width=device-width, initial-scale=1.0'>
  <title>Document</title>
  <script src='../vue.js'></script>
</head>

<body>
  <div id='app'>
    <h1>{{count}}</h1>
    <!-- v-on可以简写为@ -->
    <button @click="add">累加</button>
    <br>
    <!-- v-on事件函数 调不调用都可以 加括号只是为了方便传参,不加括号就是不用传参 -->
    <button @click="decrement($event)">类减</button>
    <!-- e和形参同时使用 -->
    <br>
    <button @click="addN(2,$event)">自定义加减</button>
  </div>

  <script>
    Vue.config.prodactionTip = false
    const vm = new Vue({
      el: "#app",
      data() {
        return {
          count: 0
        }
      },
      methods: {
        add(e) {
          console.log(e);
          this.count++
        },
        decrement(e) {
          console.log("decrement中的e", e);
          this.count--
        },
        addN(n,e){
          console.log("addN中的e",e);
          this.count+=n
        }
      }

    })
  </script>
</body>

</html>